<?php
header('charset=utf-8');
//prevent to print anything to the std output
ob_start();

error_reporting(E_ALL ^ E_STRICT);

//define the root directory for the whole api
if(!defined('_OTEKOO_ROOT_'))
	define('_OTEKOO_ROOT_', dirname(__FILE__).'/');
	
if(!defined('_OTEKOO_CONFIG_'))
	define('_OTEKOO_CONFIG_', dirname(__FILE__).'config/');
	
if(!defined('_OTEKOO_API_'))
	define('_OTEKOO_API_', 'control/');
	
if(!defined('_OTEKOO_MODEL_'))
	define('_OTEKOO_MODEL_', 'model/');

if(!defined('_OTEKOO_UTIL_'))
	define('_OTEKOO_UTIL_', 'thirdparty/');


function _include($filename)
{
	$file = substr($filename, 0, strlen(_OTEKOO_ROOT_)) == _OTEKOO_ROOT_ ? $filename : _OTEKOO_ROOT_.$filename;
	
	if(!file_exists($file))
		$file = _OTEKOO_ROOT_.$filename.".php";
	if(!file_exists($file))
		$file = _OTEKOO_ROOT_.$filename.".inc.php";
	if(!file_exists($file))
		$file = _OTEKOO_ROOT_.$filename.".inc";
	if(file_exists($file))
	{
		require_once($file);
		return true;
	}
	return false;
}


//load the application environment (dev, test, prod,....)
$ini = _OTEKOO_CONFIG_."/environment.ini";
$env = file_exists($ini) ? parse_ini_file($ini, true) : array('environment'=>'dev');
define('_OTEKOO_ENV_', $env['environment']);

_include("control/APIBootstrap");

$api = new APIBootstrap();

$api->bootstrap();